# encoding: utf-8
from flask_marshmallow import base_fields

from app.modules.apps.schemas import AppBaseSchema
from flask_restplus_patched import ModelSchema
from app.modules.common.schemas import BaseSchema
from .models import EntranceInfo


class EntranceBaseSchema(ModelSchema):
    apps = base_fields.Nested(
        AppBaseSchema,
        many = True
    )
    class Meta:
        model = EntranceInfo
        fields = (
            'id',
            'type',
            'hosts',
            'user',
            'current_status',
            'expect_status',
            'env_name',
            'zone_code',
            'prefix',
            'suffix',
            'update_time',
            'error_desc',
            'apps',
            'group',
            'is_overtime',
        )


class EntranceListSchema(BaseSchema):
    data = base_fields.Nested(
        EntranceBaseSchema,
        many = True
    )

    class Meta:
        fields = BaseSchema.Meta.fields + (
            'data',
        )
